Component({
  properties: {
    title: {
      type: String,
      value: '甜点食谱'
    },
    showBack: {
      type: Boolean,
      value: false
    },
    fixed: {
      type: Boolean,
      value: true
    },
    background: {
      type: String,
      value: '#FFF5E0'
    }
  },
  
  data: {
    statusBarHeight: 0,
    navBarHeight: 0
  },
  
  lifetimes: {
    attached() {
      const systemInfo = wx.getSystemInfoSync();
      const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
      
      // 计算导航栏高度
      const statusBarHeight = systemInfo.statusBarHeight;
      const navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height;
      
      this.setData({
        statusBarHeight,
        navBarHeight
      });

      // 触发事件通知页面导航栏高度
      this.triggerEvent('heightChange', {
        height: statusBarHeight + navBarHeight
      });
    }
  },
  
  methods: {
    // 返回上一页
    onBack() {
      wx.navigateBack({
        delta: 1,
        fail() {
          wx.switchTab({
            url: '/pages/index/index'
          });
        }
      });
    }
  }
}); 